package chapter12;

/**
 * @author : DuJiabao
 * @Date : 2021/2/20 15:01
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class StackTraceTest {
  public static void f() throws OneException {
    System.out.println("originating the exception in f()");
    throw new OneException("throw from f()");
  }

  public static void main(String[] args) {
    try {
      try {
        f();
      } catch (OneException e) {
        System.out.println("Caught in inner try, e.printStackTrace()");
        e.printStackTrace(System.out);
        throw new TwoException("from inner try");
      }
    } catch (TwoException e) {
      System.out.println("Caught in outer try, e.printStackTrace()");
      e.printStackTrace(System.out);
    }
  }
}

class OneException extends Exception {
  public OneException(String message) {
    super(message);
  }
}

class TwoException extends Exception {
  public TwoException(String message) {
    super(message);
  }
}